package com.sec.android.app.myfiles.shadow.custom;

import com.sec.android.app.myfiles.log.Log;

import junit.framework.Assert;

import org.robolectric.annotation.Implementation;
import org.robolectric.annotation.Implements;

/**
 * Created by jaebae on 2016-06-30.
 */

@Implements(Log.class)
public class ShadowMyFilesLog {
    static StringBuilder mLogMsgBuilder;
    public static boolean mEnableVerifyLog = false;

    public static void setEnableVerifyLog(boolean enable) {
        mEnableVerifyLog = enable;
        mLogMsgBuilder = null;
        if (mEnableVerifyLog) {
            mLogMsgBuilder = new StringBuilder();
        }
    }

    public static void verifyLog(String msg) {
        boolean bRet = false;

        if (mLogMsgBuilder != null) {
            int index = mLogMsgBuilder.indexOf(msg, 0);
            bRet = index >= 0;
        }

        Assert.assertTrue(msg, bRet);
    }

    @Implementation
    public static void __staticInitializer__() {

    }

    @Implementation
    public static void d(Object obj, String msg) {
        if (mEnableVerifyLog) {
            mLogMsgBuilder.append(msg);
        }
    }

    @Implementation
    public static void a(Object obj, String msg) {
        if (mEnableVerifyLog) {
            mLogMsgBuilder.append(msg);
        }
    }

    @Implementation
    public static void i(Object obj, String msg) {
        if (mEnableVerifyLog) {
            mLogMsgBuilder.append(msg);
        }
    }

    @Implementation
    public static void e(Object obj, String msg) {
        if (mEnableVerifyLog) {
            mLogMsgBuilder.append(msg);
        }
    }

    @Implementation
    public static void w(Object obj, String msg) {
        if (mEnableVerifyLog) {
            mLogMsgBuilder.append(msg);
        }
    }

    @Implementation
    public static void d(String tag, String msg) {
        if (mEnableVerifyLog) {
            mLogMsgBuilder.append(msg);
        }
    }

    @Implementation
    public static void a(String tag, String msg) {
        if (mEnableVerifyLog) {
            mLogMsgBuilder.append(msg);
        }
    }

    @Implementation
    public static void e(String tag, String msg) {
        if (mEnableVerifyLog) {
            mLogMsgBuilder.append(msg);
        }
    }

    @Implementation
    public static void w(String tag, String msg) {
        if (mEnableVerifyLog) {
            mLogMsgBuilder.append(msg);
        }
    }

    @Implementation
    public static void sluggish(Log.SluggishType type) {
    }
}
